home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / vbasic / bmpvws.zip / BMPVIEW.FRM < prev    next >
Text File  |  1993-09-21  |  8KB  |  289 lines

  1. VERSION 2.00
  2. Begin Form BMPView 
  3.    Caption         =   "Bitmap Viewer 2.0"
  4.    ClientHeight    =   600
  5.    ClientLeft      =   3696
  6.    ClientTop       =   2880
  7.    ClientWidth     =   2040
  8.    ClipControls    =   0   'False
  9.    ControlBox      =   0   'False
  10.    FontBold        =   0   'False
  11.    FontItalic      =   0   'False
  12.    FontName        =   "MS Sans Serif"
  13.    FontSize        =   7.8
  14.    FontStrikethru  =   0   'False
  15.    FontTransparent =   0   'False
  16.    FontUnderline   =   0   'False
  17.    Height          =   972
  18.    Icon            =   BMPVIEW.FRX:0000
  19.    KeyPreview      =   -1  'True
  20.    Left            =   3672
  21.    LinkTopic       =   "Form1"
  22.    MaxButton       =   0   'False
  23.    MinButton       =   0   'False
  24.    ScaleHeight     =   600
  25.    ScaleWidth      =   2040
  26.    Top             =   2532
  27.    Width           =   2088
  28.    Begin PictureBox Picture1 
  29.       AutoSize        =   -1  'True
  30.       ClipControls    =   0   'False
  31.       Enabled         =   0   'False
  32.       Height          =   36
  33.       Left            =   0
  34.       ScaleHeight     =   12
  35.       ScaleWidth      =   24
  36.       TabIndex        =   0
  37.       Top             =   0
  38.       Visible         =   0   'False
  39.       Width           =   48
  40.    End
  41.    Begin Image Image1 
  42.       Height          =   612
  43.       Left            =   0
  44.       Stretch         =   -1  'True
  45.       Top             =   0
  46.       Width           =   2052
  47.    End
  48. End
  49. Option Explicit
  50.  
  51. Sub Form_KeyDown (Keycode As Integer, Shift As Integer)
  52.  
  53. Dim ShiftDown, AltDown, CtrlDown, Txt, F12, F4
  54.  
  55.     Const KEY_F4 = &H73
  56.     Const KEY_F12 = &H7B
  57.     Const SHIFT_MASK = 1
  58.     Const CTRL_MASK = 2
  59.     Const ALT_MASK = 4
  60.     
  61.     ShiftDown = (Shift And SHIFT_MASK) > 0
  62.     AltDown = (Shift And ALT_MASK) > 0
  63.     CtrlDown = (Shift And CTRL_MASK) > 0
  64.     F12 = (Keycode = KEY_F12)
  65.     F4 = (Keycode = KEY_F4)
  66.     
  67.     If (ShiftDown And F12) Then
  68.         WindowState = MINIMIZED
  69.         'Picture = Image1.Picture
  70.         'Form_Resize
  71.     End If
  72.     
  73.     If (CtrlDown And F12) Then
  74.         WindowState = normal
  75.     End If
  76.     
  77.     If (AltDown And F12) Then
  78.         WindowState = MAXIMIZED
  79.     End If
  80.     
  81.     If (AltDown And F4) Then
  82.         Form_Unload 0
  83.     End If
  84.  
  85. End Sub
  86.  
  87. Sub Form_Load ()
  88.     
  89.     ReadINI
  90.  
  91.     Picture1.Top = 0
  92.     Picture1.Left = 0
  93.     Image1.Top = 0
  94.     Image1.Left = 0
  95.     Image1.Width = ScaleWidth
  96.     Image1.Height = ScaleHeight
  97.  
  98.     Load OpenBitMap
  99.     Load BmpABout
  100.  
  101.  
  102.     If (BMPFileName <> "") Then
  103.         ImageLoad
  104.         Top = ViewTop
  105.         Left = ViewLeft
  106.         Height = ViewHeight
  107.         ViewAllowResize = True
  108.         Width = ViewWidth
  109.     Else
  110.         NotTopMost
  111.         OpenBitMap.Show 1
  112.     End If
  113.     
  114.     If (OpenBitMap.OnTop = True) Then
  115.         Topmost
  116.     Else
  117.         NotTopMost
  118.     End If
  119.  
  120. End Sub
  121.  
  122. Sub Form_Resize ()
  123.     
  124.     If (ScaleWidth > 1) And (ScaleHeight > 1) And (ViewAllowResize) Then
  125.         If (OpenBitMap.Aspect = True) And (WindowState = normal) Then
  126.             Width = (ScaleHeight * ViewAspect) + ViewBorder
  127.         End If
  128.         Image1.Width = ScaleWidth
  129.         Image1.Height = ScaleHeight
  130.     End If
  131.     
  132. End Sub
  133.  
  134. Sub Form_Unload (Cancel As Integer)
  135.     
  136.     BMPView.Image1.Picture = LoadPicture("")
  137.     Unload OpenBitMap
  138.     Unload BmpABout
  139.     Unload BMPView
  140.     End
  141.  
  142. End Sub
  143.  
  144. Sub Image1_DblClick ()
  145.     
  146.     NotTopMost
  147.  
  148.     OpenBitMap.Show 1
  149.     
  150. End Sub
  151.  
  152. Sub Image1_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single)
  153.         
  154.     If (Button And 2) Then
  155.         ViewAllowResize = False
  156.         If (Caption = "") Then
  157.             ViewCaption = True
  158.             Caption = "Bitmap Viewer"
  159.         Else
  160.             ViewCaption = False
  161.             Caption = ""
  162.         End If
  163.         ViewAllowResize = True
  164.     Else
  165.         PixStartX = (BMPView.Left) / TPRatio
  166.         PixStartY = (BMPView.Top) / TPRatio
  167.         PixOffsetX = Int(X / TPRatio)
  168.         PixOffsetY = Int(Y / TPRatio)
  169.         OkToMove = True
  170.         GhostForm PixStartX, PixStartY, PixStartX + (BMPView.Width / TPRatio), PixStartY + (BMPView.Height / TPRatio)
  171.     End If
  172.  
  173. End Sub
  174.  
  175. Sub Image1_MouseMove (Button As Integer, Shift As Integer, X As Single, Y As Single)
  176.     
  177.     If Button = 1 And OkToMove = True Then
  178.         OkToMove = False
  179.         PixX = Int(X / TPRatio) - PixOffsetX
  180.         PixY = Int(Y / TPRatio) - PixOffsetY
  181.         GhostForm PixStartX, PixStartY, PixStartX + (BMPView.Width / TPRatio), PixStartY + (BMPView.Height / TPRatio)
  182.         GhostForm PixStartX + PixX, PixStartY + PixY, PixStartX + PixX + (BMPView.Width / TPRatio), PixStartY + PixY + (BMPView.Height / TPRatio)
  183.         PixOffsetX = Int(X / TPRatio)
  184.         PixOffsetY = Int(Y / TPRatio)
  185.         PixStartX = PixStartX + PixX
  186.         PixStartY = PixStartY + PixY
  187.         OkToMove = True
  188.     End If
  189.  
  190. End Sub
  191.  
  192. Sub Image1_MouseUp (Button As Integer, Shift As Integer, X As Single, Y As Single)
  193.     
  194.     If Button = 1 And OkToMove = True Then
  195.         GhostForm PixStartX, PixStartY, PixStartX + (BMPView.Width / TPRatio), PixStartY + (BMPView.Height / TPRatio)
  196.         BMPView.Move (PixStartX) * TPRatio, (PixStartY) * TPRatio
  197.     End If
  198.     
  199. End Sub
  200.  
  201. Sub ReadINI ()
  202.     
  203.     Dim INISection As String
  204.     Dim NoTitle As String
  205.     Dim SaveSet As String
  206.     Dim Always As String
  207.     Dim AspectRatio As String
  208.     Dim INIChan As Integer
  209.     Dim Tmp As Integer
  210.     Dim LIN As String
  211.  
  212.     On Error GoTo NOINI
  213.     INIChan% = 1
  214.     BMPFileName = ""
  215.     ViewCaption = True
  216.     OpenBitMap.SaveSettings = False
  217.     OpenBitMap.OnTop = False
  218.     OpenBitMap.Aspect = False
  219.     
  220.     Open "C:\WINDOWS\BMPVIEW.INI" For Input As #INIChan%
  221.     
  222.     While (EOF(INIChan%) = 0)
  223.         
  224.         Line Input #INIChan%, LIN$
  225.         If Trim$(LIN$) <> "" Then
  226.             If (Left$(LIN$, 1) = "[") Then
  227.                 Tmp% = InStr(LIN$, "]")
  228.                 If (Tmp% > 2) Then
  229.                     INISection = Mid$(LIN$, 2, Tmp% - 2)
  230.                 Else
  231.                     INISection = Mid$(LIN$, 2)
  232.                 End If
  233.             Else
  234.                 Select Case INISection
  235.                     Case "Current Bitmap"
  236.                         BMPFileName = LIN$
  237.                     Case "Top"
  238.                         ViewTop = Val(LIN$)
  239.                     Case "Left"
  240.                         ViewLeft = Val(LIN$)
  241.                     Case "Height"
  242.                         ViewHeight = Val(LIN$)
  243.                     Case "Width"
  244.                         ViewWidth = Val(LIN$)
  245.                     Case "No Title"
  246.                         NoTitle = LIN$
  247.                     Case "Save Settings"
  248.                         SaveSet = LIN$
  249.                     Case "Always on top"
  250.                         Always = LIN$
  251.                     Case "Aspect Ratio"
  252.                         AspectRatio = LIN$
  253.                     Case Else
  254.                 End Select
  255.             End If
  256.         End If
  257.  
  258.     Wend
  259.     Close #INIChan%
  260.     If (NoTitle = "Yes") Then
  261.         Caption = ""
  262.         ViewCaption = False
  263.     End If
  264.     If (SaveSet = "Yes") Then
  265.         OpenBitMap.SaveSettings = True
  266.     End If
  267.     If (Always = "Yes") Then
  268.         OpenBitMap.OnTop = True
  269.     End If
  270.     If (AspectRatio = "Yes") Then
  271.         OpenBitMap.Aspect = True
  272.     End If
  273.     
  274. Exit Sub
  275.  
  276. NOINI:
  277.         If (Err = 53) Then
  278.             Exit Sub
  279.         Else
  280.             MsgBox "Fatal error" & Str$(Err) & " in BMPView"
  281.         End If
  282.         
  283.         Form_Unload 0
  284.  
  285.         End
  286.  
  287. End Sub
  288.  
  289.